//
//  JourneyCollectionViewCell.m
//  Travel_M_Travel
//
//  Created by APPLE10 on 15-3-23.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "JourneyCollectionViewCell.h"
#import "UIImageView+WebCache.h"
@implementation JourneyCollectionViewCell

-(void)dealloc
{
    [_fourImageView release];
    [_jourDetilData release];
    [_nameLable release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.fourImageView = [[UIImageView alloc]init];
        _fourImageView.backgroundColor = [UIColor greenColor];
        _fourImageView.contentMode = UIViewContentModeScaleAspectFill;
        _fourImageView.clipsToBounds = YES;
        _fourImageView.layer.cornerRadius = 5;
        [self addSubview:_fourImageView];
        [_fourImageView release];
        
        self.nameLable = [[UILabel alloc]init];
        _nameLable.textAlignment = NSTextAlignmentCenter;
//        _nameLable.backgroundColor = [UIColor whiteColor];
        _nameLable.textColor = [UIColor whiteColor];
        _nameLable.highlighted = YES;
        _nameLable.shadowColor = [UIColor whiteColor];
        _nameLable.font = [UIFont fontWithName:@"MarkerFelt-Wide" size:17];
        [_fourImageView addSubview:_nameLable];
        [_nameLable release];
        
        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.fourImageView.frame = layoutAttributes.bounds;
    self.nameLable.frame = CGRectMake(_fourImageView.frame.size.width / 2, _fourImageView.frame.size.height * 2 / 3, _fourImageView.frame.size.width / 2, _fourImageView.frame.size.height / 3);
}

- (void)setJourDetilData:(JourneyDetilDataSource *)jourDetilData
{
    if (_jourDetilData != jourDetilData) {
        [_jourDetilData release];
        _jourDetilData = [jourDetilData retain];
    }
    NSString *str = _jourDetilData.cover_s;
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:str];
    [_fourImageView setImageWithURL:url];
    _nameLable.text = _jourDetilData.name;
}


@end
